﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Redmine.Net.Api;
using RedmineWorkerDotNET.App.Classes;
using Redmine.Net.Api.Types;
using System.Collections.Specialized;

namespace RedmineWorkerDotNET.App
{
    public partial class FormLogin : Form
    {
        public FormLogin()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (RedmineClient.Login(txtUser.Text, txtPass.Text))
            {
                if (chkRemember.Checked)
                {
                    RedmineConfiguration.SaveCredentials = true;
                    RedmineConfiguration.Username = txtUser.Text;
                    RedmineConfiguration.Password = txtPass.Text;
                }
                else
                {
                    RedmineConfiguration.SaveCredentials = false;
                    RedmineConfiguration.Username = String.Empty;
                    RedmineConfiguration.Password = String.Empty;
                }

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
    }
}
